package com.slfx.synchronize;

/**
 * @author ：slfx
 * @date ：Created in 2020/7/3
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 * @description:
 **/
public class Juc_LockAppend2 {

    Object object = new Object();

    private void method() {
        synchronized (object) {
            System.out.println(1);
        }

        synchronized (object) {
            System.out.println(2);
        }

        synchronized (object) {
            System.out.println(3);
        }
    }

    private void method2() {
        synchronized (object) {
            System.out.println(1);
            System.out.println(2);
            System.out.println(3);
        }
    }

    //锁消除
    private void method3() {
        Object object1 = new Object();
        synchronized (object1) {
            //业务逻辑
            System.out.println(1);
            //业务逻辑
        }
    }
}
